# 7-3 贪心的交易【函数】


import random
def max_profit(prices):
    total_profit = 0
    for i in range(1, len(prices)):
        if prices[i] > prices[i-1]:
            total_profit += prices[i] - prices[i-1]
    return total_profit

def main():
    days = int(input())
    random_seed = int(input())
    random.seed(random_seed)
    prices = [random.randint(1, 100) for _ in range(days)]
    print(prices)
    print(max_profit(prices))

main()